<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Attachment extends Model
{
    protected $guarded = [];
    protected $hidden = ['created_at', 'updated_at'];
    public function attachmentable()
    {
        return $this->morphTo();
    }

    public function getUrlAttribute($value)
    {
        if (request()->method() !== "DELETE") {
            return asset('storage/'.$value);
        }
        return $value;
    }
}
